package Main;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class SellFrame extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SellFrame frame = new SellFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SellFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		JLabel lblNewLabel = new JLabel("请输入您的商品名称");
		lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		lblNewLabel.setForeground(Color.BLUE);
		lblNewLabel.setBounds(22, 31, 224, 36);
		contentPane.add(lblNewLabel);
		
		JLabel label = new JLabel("请输入您的商品单价");
		label.setForeground(Color.BLUE);
		label.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		label.setBounds(22, 73, 224, 36);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("请输入您的商品数量");
		label_1.setForeground(Color.BLUE);
		label_1.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		label_1.setBounds(22, 116, 224, 36);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("请输入您的商品描述");
		label_2.setForeground(Color.BLUE);
		label_2.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		label_2.setBounds(22, 162, 224, 36);
		contentPane.add(label_2);
		
		textField = new JTextField();
		textField.setBounds(267, 31, 157, 34);
		contentPane.add(textField);
		textField.setColumns(10);
		
		textField_1 = new JTextField();
		textField_1.setColumns(10);
		textField_1.setBounds(267, 73, 157, 34);
		contentPane.add(textField_1);
		
		textField_2 = new JTextField();
		textField_2.setColumns(10);
		textField_2.setBounds(267, 116, 157, 34);
		contentPane.add(textField_2);
		
		textField_3 = new JTextField();
		textField_3.setColumns(10);
		textField_3.setBounds(267, 162, 157, 34);
		contentPane.add(textField_3);
		
		JButton btnNewButton = new JButton("返回");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Fframe f = new Fframe();
				f.setVisible(true);
				dispose();
			}
		});
		btnNewButton.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		btnNewButton.setForeground(Color.BLUE);
		btnNewButton.setBounds(293, 206, 117, 45);
		contentPane.add(btnNewButton);
		
		JButton button = new JButton("确认");
		button.addMouseListener(new MouseAdapter() {
			GoodsSQL s = new GoodsSQL();
			@Override
			public void mouseClicked(MouseEvent e) {
				String value1 = textField.getText().trim();
				String value2 = textField_1.getText().trim();
				String value3 = textField_2.getText().trim();
				String value4 = textField_3.getText().trim();
				s.Sell(value1, Double.parseDouble(value2), Integer.parseInt(value3), value4);
			}
		});
		button.setForeground(Color.BLUE);
		button.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		button.setBounds(22, 206, 117, 45);
		contentPane.add(button);
	}

}
